package com.example.administrator.myapplication.Model;

import android.util.Log;

import com.example.administrator.myapplication.Bean.Picture;
import com.example.administrator.myapplication.Http.Api;
import com.example.administrator.myapplication.Http.RetrofitHelper;
import com.example.administrator.myapplication.Presenter.IPictureListener;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Administrator on 2019/10/14 0014.
 */

public class PictureModel implements IPictureModel{
    @Override
    public void getRamdomPicture(final IPictureListener iPictureListener) {
        RetrofitHelper retrofitHelper = new RetrofitHelper(Api.Server_Host);
        retrofitHelper.getRamdomPicture().enqueue(new Callback<Picture>() {
            @Override
            public void onResponse(Call<Picture> call, Response<Picture> response) {
                iPictureListener.success(response.body());
                Log.e("wwwww",response.body().getFileName());
            }

            @Override
            public void onFailure(Call<Picture> call, Throwable t) {
                iPictureListener.error(t.toString());
            }
        });
    }
}
